import { msg } from "@/utils/msg";
export default function (type : "POST" | "GET", res : any) {
	if (type === "GET") {
		if (Array.isArray(res)) {
			return res as any[];
		} else {
			if (res.Result.ResponseStatus.Errors[0].Message == "会话信息已丢失，请重新登录") {
				msg('请重试')
			} else {
				uni.showModal({
					title: "提示",
					content: res.Result.ResponseStatus.Errors[0].Message,
					showCancel: false,
				});
			}
			return {
				Result: {
					ResponseStatus: {
						IsSuccess: false,
					},
				},
			};
		}
	} else if (type === "POST") {
		// 肯定是对象
		// res = res as { Result: any };
		if (res.Result.ResponseStatus.IsSuccess == true) {
			msg(`操作成功!`);
			return res as { Result : any };
		} else {
			uni.showModal({
				title: "提示",
				content: res.Result.ResponseStatus.Errors[0].Message,
				showCancel: false,
			});

			return {
				Result: {
					ResponseStatus: {
						IsSuccess: false,
					},
				},
			};
		}
	}
}